package com.qjs.activity.rookie.interceptor;

import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;



public class HandleRoutePowerInterceptor implements HandlerInterceptor {

	/**
	 * 在DispatcherServlet完全处理完请求后被调用
	 */

	public void afterCompletion(HttpServletRequest req,
			HttpServletResponse res, Object arg2, Exception e) throws Exception {

	}

	/**
	 * 在业务处理器处理请求执行完成后,生成视图之前执行的动作
	 */

	public void postHandle(HttpServletRequest req, HttpServletResponse res,
			Object obj, ModelAndView mav) throws Exception {
	}
	

	/**
	 * 根据登陆user级别获取要拦截的路由
	 * 再获取user访问的路由是否存在拦截的路由
	 * 如存在retrun false
	 */
	public boolean preHandle(HttpServletRequest req, HttpServletResponse res,
			Object obj) throws Exception {
//		User user = (User) req.getSession().getAttribute("SESSION_USER");
//		if(req.getMethod().equals("POST") || user == null){
//			return true;
//		}
//		String routePower[] = DictionaryData.USER_STATUS_POWER().get(user.getStatus());
//		if(Util.notNull(routePower)){
//			String url = req.getRequestURI();  
//			for (int i = 0; i < routePower.length; i++) {
//				int num = url.indexOf(routePower[i]);
//				if(num>0){
//					res.sendRedirect(req.getContextPath() + "/power/jump");
//					return false;
//				}	
//			}
//		}
		return true;
	}

}
